package com.iut.sujet1.metier;

import java.util.Arrays;

public class Carnet {

	private Personne[] tab;
	private int nbE;
	final static int defaultTaille = 100;


	public Carnet() {
		super();
		setNbE(0);
		setTab(new Personne[defaultTaille]);
	}

	public Carnet(int taille) {
		super();
		setNbE(0);
		setTab(new Personne[taille>0?taille:defaultTaille]);
	}


	public Personne[] getTab() {
		return tab;
	}

	public void setTab(Personne[] tab) {
		this.tab = tab;
	}

	/**
	 * @return the nbE
	 */
	public int getNbE() {
		return nbE;
	}



	/**
	 * @param nbE the nbE to set
	 */
	public void setNbE(int nbE) {
		this.nbE = nbE;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Carnet [tab=" + Arrays.toString(tab) + ", nbE=" + nbE + "]";
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + nbE;
		result = prime * result + Arrays.hashCode(tab);
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Carnet)) {
			return false;
		}
		Carnet other = (Carnet) obj;
		if (nbE != other.nbE) {
			return false;
		}
		if (!Arrays.equals(tab, other.tab)) {
			return false;
		}
		return true;
	}


	
	
}
